package offer;

public class Solution66 {
    public int[] constructArr(int[] a) {
        int n = a.length;
        int[] front = new int[n + 1], back = new int[n + 1];
        front[0] = 1;
        back[n] = 1;
        for (int i = 0; i < n; i++) {
            front[i + 1] = front[i] * a[i];
        }
        for (int i = n - 1; i >= 0; i--) {
            back[i] = back[i + 1] * a[i];
        }
        int[] b = new int[n];
        for (int i = 0; i < n; i++) {
            b[i] = front[i] * back[i + 1];
        }
        return b;
    }
}
